package com.lihua.newideas.mapper;

import com.lihua.newideas.pojo.UserManuscript;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/*
* 用户投稿
* */
@Mapper
@Repository
public interface UserManuscriptMapper {
    /*
    * 添加稿件
    * */
    void insertUserManuscript(UserManuscript userManuscript);

    /*
    * 根据id进行查找
    * */
    @Select("select * from user_manuscript where id = #{id}")
    UserManuscript queryManuscriptById(@Param("id") Long id);

    /*
    * 根据username查询稿件
    * */
    @Select("select * from user_manuscript where user_name = #{userName}")
    List<UserManuscript> queryUserManuscriptByUserName(@Param("userName") String userName);

    /*
    * 查询全部
    * */
    @Select("select * from user_manuscript where manuscript_status = #{manuscriptStatus} ")
    List<UserManuscript> queryUserManuscriptByStatus(@Param("manuscriptStatus") long status);

    /*
     * 根据id修改状态
     * */
    @Update("update user_manuscript set manuscript_status = #{manuscriptStatus} where id = #{id} ")
    void updateManuscriptStatusById(@Param("id") long id,@Param("manuscriptStatus") long manuscriptStatus);
}
